package com.nami.im.network.model.packet.v2;

import lombok.Data;

import java.io.Serializable;

/**
 * 描述：
 *
 * @Author: lbc
 * @Date: 2023-07-14 13:22
 * @email: 594599620@qq.com
 * @Description: keep coding
 */
@Data
public class Packet implements Serializable {

    private static final long serialVersionUID = -9325988132503202L;

    private byte magic;

    private byte version;

    private byte cmd;

    /**
     * mqtt 为三个级别
     * qos = 0
     * qos = 1
     * qos = 2
     *
     * #没有重试
     * qos = 0
     * #有重试，且多次
     * qos = 1
     *
     */
    private byte qos;

    /**
     * 4字节 包体长度
     */
    private int length;

    /**
     * 业务
     */
    private byte[] body;

    /**
     * 获取包数据长度
     *
     * @return
     */
    public int getLength() {
        if (null == body) {
            return 0;
        }
        return body.length;
    }

}
